package com.polaris.live.viewmodel.live

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.net.liveService
import com.polaris.live.resp.back_resp.PartyMemberResp
import com.polaris.live.resp.base.ListResp

/**
 * RoomInfoViewModel
 *
 * @author Created by 半仙 on 2023/10/10/010 10:07
 */
class RoomInfoMemberViewModel : BaseViewModel() {

    var pageNumber = 0L
    private val pageSize = 20L

    var membersSummaryLiveData = MutableLiveData<ResultState<PartyMemberResp>>()

    /**
     * 获取成员汇总
     */
    fun membersSummary(roomId: String) {
        request({ liveService.membersSummary(roomId) }, membersSummaryLiveData)
    }

    var membersPageLiveData = MutableLiveData<ResultState<ListResp<UserBasicVo>>>()

    /**
     * 获取成员
     */
    fun membersPage(roomId: String) {
        request({ liveService.membersPage(roomId, pageNumber, pageSize) }, membersPageLiveData)
    }

    var kickMembersLiveData = MutableLiveData<ResultState<UserBasicVo>>()

    /**
     * 踢出成员
     */
    fun kickMembers(roomId: String, user: UserBasicVo) {
        request({ liveService.kickMembers(roomId, user.userId) }, {
            kickMembersLiveData.value = ResultState.onAppSuccess(user)
        }, {
            kickMembersLiveData.value = ResultState.onAppError(it)
        })
    }

}